From e5e456c0d029cdbc739d5ea0b09c596a279bacac Mon Sep 17 00:00:00 2001 From: Andreas Beckmann Date: Mon, 14 Dec 2020 21:05:48 +0100 Subject: [PATCH] [PATCH 2/2] restore visibility hidden Gbp-Pq: Name 0002-restore-visibility-hidden.patch --- include/pocl_cache.h | 8 ++++++ include/pocl_file_util.h | 8 ++++++ lib/CL/clCreateContext.c | 2 +- lib/CL/devices/bufalloc.h | 8 ++++++ lib/CL/devices/common.h | 48 ++++++++++++++++++++++++++++++++ lib/CL/devices/devices.c | 2 ++ lib/CL/devices/devices.h | 16 +++++++++++ lib/CL/devices/pocl_local_size.h | 10 +++++++ lib/CL/devices/prototypes.inc | 13 ++++++++- lib/CL/devices/pthread/pthread.c | 1 + lib/CL/pocl_cl.h | 4 +-- lib/CL/pocl_cq_profiling.h | 8 ++++++ lib/CL/pocl_debug.h | 29 +++++++++++++++++++ lib/CL/pocl_hash.h | 8 ++++++ lib/CL/pocl_llvm.h | 9 ++++++ lib/CL/pocl_runtime_config.h | 18 ++++++++++++ lib/CL/pocl_timing.h | 8 ++++++ lib/CL/pocl_util.h | 48 ++++++++++++++++++++++++++++++++ 18 files changed, 244 insertions(+), 4 deletions(-) diff --git a/include/pocl_cache.h b/include/pocl_cache.h index 377aa21..92ef284 100644 --- a/include/pocl_cache.h +++ b/include/pocl_cache.h @@ -36,6 +36,10 @@ extern "C" { #include +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + int pocl_cache_init_topdir (); int @@ -120,6 +124,10 @@ void pocl_cache_final_binary_path (char *final_binary_path, cl_program program, unsigned device_i, cl_kernel kernel, _cl_command_node *command, int specialize); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + #ifdef __cplusplus } diff --git a/include/pocl_file_util.h b/include/pocl_file_util.h index a6d73f0..b6b90f8 100644 --- a/include/pocl_file_util.h +++ b/include/pocl_file_util.h @@ -31,6 +31,10 @@ extern "C" { #endif +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + /* Remove a directory, recursively */ int pocl_rm_rf(const char* path); @@ -67,6 +71,10 @@ int pocl_mk_tempdir (char *output, const char *prefix); int pocl_mk_tempname (char *output, const char *prefix, const char *suffix, int *ret_fd); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + #ifdef __cplusplus } #endif diff --git a/lib/CL/clCreateContext.c b/lib/CL/clCreateContext.c index 3f2c3b3..8dbd660 100644 --- a/lib/CL/clCreateContext.c +++ b/lib/CL/clCreateContext.c @@ -117,7 +117,7 @@ int context_set_properties(cl_context context, } unsigned cl_context_count = 0; -pocl_lock_t pocl_context_handling_lock = POCL_LOCK_INITIALIZER; +pocl_lock_t pocl_context_handling_lock __attribute__((visibility("hidden"))) = POCL_LOCK_INITIALIZER; CL_API_ENTRY cl_context CL_API_CALL POname(clCreateContext)(const cl_context_properties * properties, diff --git a/lib/CL/devices/bufalloc.h b/lib/CL/devices/bufalloc.h index e22f3e4..ae4a6f0 100644 --- a/lib/CL/devices/bufalloc.h +++ b/lib/CL/devices/bufalloc.h @@ -40,6 +40,10 @@ extern "C" { #include "pocl_cl.h" +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + typedef pocl_lock_t ba_lock_t; #define BA_LOCK(LOCK) POCL_LOCK(LOCK) @@ -163,6 +167,10 @@ print_chunk (chunk_info_t *chunk); void print_chunks (chunk_info_t *first); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + #ifdef __cplusplus } #endif diff --git a/lib/CL/devices/common.h b/lib/CL/devices/common.h index e9a6bca..d6e1bcd 100644 --- a/lib/CL/devices/common.h +++ b/lib/CL/devices/common.h @@ -60,15 +60,27 @@ extern "C" { #endif +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + int llvm_codegen (char *output, unsigned device_i, cl_kernel kernel, cl_device_id device, _cl_command_node *command, int specialize); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + void fill_dev_image_t (dev_image_t *di, struct pocl_argument *parg, cl_device_id device); void fill_dev_sampler_t (dev_sampler_t *ds, struct pocl_argument *parg); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + void pocl_copy_mem_object (cl_device_id dest_dev, cl_mem dest, size_t dest_offset, cl_device_id source_dev, cl_mem source, @@ -79,40 +91,76 @@ void pocl_migrate_mem_objects (_cl_command_node *node); void pocl_scheduler (_cl_command_node * volatile * ready_list, pthread_mutex_t *lock_ptr); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + void pocl_exec_command (_cl_command_node * volatile node); void pocl_ndrange_node_cleanup(_cl_command_node *node); + +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif void pocl_mem_objs_cleanup (cl_event event); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + void pocl_broadcast (cl_event event); void pocl_init_dlhandle_cache (); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + char *pocl_check_kernel_disk_cache (_cl_command_node *cmd, int specialized); size_t pocl_cmd_max_grid_dim_width (_cl_command_run *cmd); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + void pocl_check_kernel_dlhandle_cache (_cl_command_node *command, unsigned initial_refcount, int specialize); void pocl_release_dlhandle_cache (_cl_command_node *cmd); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + void pocl_setup_device_for_system_memory(cl_device_id device); void pocl_reinit_system_memory(); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + void pocl_set_buffer_image_limits(cl_device_id device); void* pocl_aligned_malloc_global_mem(cl_device_id device, size_t align, size_t size); void pocl_free_global_mem(cl_device_id device, void *ptr, size_t size); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + void pocl_print_system_memory_stats(); void pocl_calculate_kernel_hash (cl_program program, unsigned kernel_i, unsigned device_i); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + void pocl_init_default_device_infos (cl_device_id dev); #ifdef __cplusplus diff --git a/lib/CL/devices/devices.c b/lib/CL/devices/devices.c index 9bf622f..49d16e6 100644 --- a/lib/CL/devices/devices.c +++ b/lib/CL/devices/devices.c @@ -80,7 +80,9 @@ /* the enabled devices */ static struct _cl_device_id* pocl_devices = NULL; unsigned int pocl_num_devices = 0; +#if 0 unsigned int pocl_num_device_types = 0; +#endif /* Init function prototype */ typedef void (*init_device_ops)(struct pocl_device_ops*); diff --git a/lib/CL/devices/devices.h b/lib/CL/devices/devices.h index 2c8c222..15437a1 100644 --- a/lib/CL/devices/devices.h +++ b/lib/CL/devices/devices.h @@ -28,6 +28,10 @@ #include "../pocl_cl.h" #include "config.h" +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -62,6 +66,10 @@ unsigned int pocl_get_device_type_count(cl_device_type device_type); */ unsigned int pocl_get_devices(cl_device_type device_type, struct _cl_device_id **devices, unsigned int num_devices); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + /** * \brief Return the count of a specific device in the env var POCL_DEVICES * \param dev_type a string describing the device ("basic" for instance) @@ -71,12 +79,20 @@ unsigned int pocl_get_devices(cl_device_type device_type, struct _cl_device_id * int pocl_device_get_env_count(const char *dev_type); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + /** * \brief Unique global memory id for devices with distinct memory from the system memory * \return Unique global mem id, id > 0. Zero is reserved for shared system memory */ int pocl_get_unique_global_mem_id(); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + /* the environment variable that lists the enabled devices */ #define POCL_DEVICES_ENV "POCL_DEVICES" diff --git a/lib/CL/devices/pocl_local_size.h b/lib/CL/devices/pocl_local_size.h index 0fb7316..738cca2 100644 --- a/lib/CL/devices/pocl_local_size.h +++ b/lib/CL/devices/pocl_local_size.h @@ -25,6 +25,7 @@ #define POCL_LOCAL_SIZE_H #include "pocl_cl.h" + /* The generic local size optimizer used by default, in case there's no target * specific one defined in the device driver. */ void pocl_default_local_size_optimizer (cl_device_id dev, size_t global_x, @@ -32,6 +33,10 @@ void pocl_default_local_size_optimizer (cl_device_id dev, size_t global_x, size_t *local_x, size_t *local_y, size_t *local_z); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + /* Can be used for devices which support only small work-groups and prefer * them to be maximally utilized to use as many of the SIMD lanes as possible. * High compute unit utilization is only a secondary goal which typicaly @@ -42,4 +47,9 @@ void pocl_wg_utilization_maximizer (cl_device_id dev, size_t global_x, size_t global_y, size_t global_z, size_t *local_x, size_t *local_y, size_t *local_z); + +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + #endif diff --git a/lib/CL/devices/prototypes.inc b/lib/CL/devices/prototypes.inc index 91987eb..3864a74 100644 --- a/lib/CL/devices/prototypes.inc +++ b/lib/CL/devices/prototypes.inc @@ -21,7 +21,16 @@ THE SOFTWARE. */ +#ifdef _MSC_VER +# define PUSH_VISIBILITY_HIDDEN +# define POP_VISIBILITY_HIDDEN +#else +# define PUSH_VISIBILITY_HIDDEN _Pragma ("GCC visibility push(hidden)") +# define POP_VISIBILITY_HIDDEN _Pragma ("GCC visibility pop") +#endif + #define GEN_PROTOTYPES(__DRV__) \ + PUSH_VISIBILITY_HIDDEN \ void pocl_##__DRV__##_submit (_cl_command_node *node, cl_command_queue cq); \ void pocl_##__DRV__##_join (cl_device_id device, cl_command_queue cq); \ void pocl_##__DRV__##_flush (cl_device_id device, cl_command_queue cq); \ @@ -31,7 +40,9 @@ void pocl_##__DRV__##_wait_event (cl_device_id device, cl_event event); \ void pocl_##__DRV__##_update_event (cl_device_id device, cl_event event); \ void pocl_##__DRV__##_free_event_data (cl_event event); \ + POP_VISIBILITY_HIDDEN \ void pocl_##__DRV__##_init_device_ops (struct pocl_device_ops *ops); \ + PUSH_VISIBILITY_HIDDEN \ cl_int pocl_##__DRV__##_uninit (unsigned j, cl_device_id device); \ cl_int pocl_##__DRV__##_reinit (unsigned j, cl_device_id device); \ cl_int pocl_##__DRV__##_init (unsigned j, cl_device_id device, \ @@ -142,4 +153,4 @@ const char *kernel_name); \ cl_int pocl_##__DRV__##_get_builtin_kernel_metadata (void *data, \ const char *kernel_name, pocl_kernel_metadata_t *target); \ - + POP_VISIBILITY_HIDDEN diff --git a/lib/CL/devices/pthread/pthread.c b/lib/CL/devices/pthread/pthread.c index d0f6d82..700eeb5 100644 --- a/lib/CL/devices/pthread/pthread.c +++ b/lib/CL/devices/pthread/pthread.c @@ -131,6 +131,7 @@ static cl_device_partition_property pthread_partition_properties[2] #define FALLBACK_MAX_THREAD_COUNT 8 +static char scheduler_initialized = 0; cl_int diff --git a/lib/CL/pocl_cl.h b/lib/CL/pocl_cl.h index fa7b1f6..f9816a6 100644 --- a/lib/CL/pocl_cl.h +++ b/lib/CL/pocl_cl.h @@ -223,8 +223,8 @@ typedef pthread_mutex_t pocl_lock_t; /* Symbol aliases are supported */ # define POname(name) PO##name - -#define POdeclsym(name) __typeof__ (name) PO##name; +# define POdeclsym(name) \ + __typeof__(name) PO##name __attribute__((visibility("hidden"))); # define POCL_ALIAS_OPENCL_SYMBOL(name) \ __typeof__(name) name __attribute__((alias ("PO" #name), visibility("default"))); # define POsymAlways(name) POCL_ALIAS_OPENCL_SYMBOL(name) diff --git a/lib/CL/pocl_cq_profiling.h b/lib/CL/pocl_cq_profiling.h index aeeaed5..893098a 100644 --- a/lib/CL/pocl_cq_profiling.h +++ b/lib/CL/pocl_cq_profiling.h @@ -46,10 +46,18 @@ #include "CL/cl.h" +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + /* This is set to 1 in case the cq profiling was enabled via POCL_TRACING=cq. */ extern int pocl_cq_profiling_enabled; void pocl_cq_profiling_init (); void pocl_cq_profiling_register_event (cl_event event); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + #endif diff --git a/lib/CL/pocl_debug.h b/lib/CL/pocl_debug.h index 9b9f905..9211b38 100644 --- a/lib/CL/pocl_debug.h +++ b/lib/CL/pocl_debug.h @@ -65,6 +65,10 @@ extern "C" { #define POCL_FILTER_TYPE_WARN 2 #define POCL_FILTER_TYPE_ERR 3 +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + /* Debugging macros. Also macros for marking unimplemented parts of specs or untested parts of the implementation. */ @@ -109,9 +113,17 @@ extern "C" { #ifdef POCL_DEBUG_MESSAGES +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + extern uint64_t pocl_debug_messages_filter; extern int stderr_is_a_tty; +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + #define POCL_DEBUGGING_ON (pocl_debug_messages_filter) #if __GNUC__ >= 2 @@ -122,11 +134,24 @@ extern "C" { #define POCL_DEBUG_HEADER(FILTER, FILTER_TYPE) \ pocl_debug_print_header (__func__, __LINE__, #FILTER, FILTER_TYPE); + +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif extern void pocl_debug_output_lock (); extern void pocl_debug_output_unlock (); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif extern void pocl_debug_messages_setup (const char *debug); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif extern void pocl_debug_print_header (const char * func, unsigned line, const char* filter, int filter_type); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif extern void pocl_debug_measure_start (uint64_t* start); extern void pocl_debug_measure_finish (uint64_t* start, uint64_t* finish, const char* msg, @@ -320,6 +345,10 @@ extern "C" { } \ while (0) +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + #ifdef __cplusplus } #endif diff --git a/lib/CL/pocl_hash.h b/lib/CL/pocl_hash.h index a9ab939..d74be24 100644 --- a/lib/CL/pocl_hash.h +++ b/lib/CL/pocl_hash.h @@ -31,6 +31,10 @@ extern "C" { #include +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + typedef struct { uint32_t state[5]; uint32_t count[2]; @@ -43,6 +47,10 @@ void pocl_SHA1_Init(SHA1_CTX* context); void pocl_SHA1_Update(SHA1_CTX* context, const uint8_t* data, const size_t len); void pocl_SHA1_Final(SHA1_CTX* context, uint8_t digest[SHA1_DIGEST_SIZE]); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + #ifdef __cplusplus } #endif diff --git a/lib/CL/pocl_llvm.h b/lib/CL/pocl_llvm.h index bd1d47f..d2807ff 100644 --- a/lib/CL/pocl_llvm.h +++ b/lib/CL/pocl_llvm.h @@ -31,6 +31,11 @@ extern "C" { /* Returns the cpu name as reported by LLVM. */ char *get_llvm_cpu_name (); + +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + /* Returns if the cpu supports FMA instruction (uses LLVM). */ int cpu_has_fma(); @@ -122,6 +127,10 @@ int pocl_llvm_link_program(cl_program program, int pocl_invoke_clang(cl_device_id Device, const char** Args); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + #ifdef __cplusplus } diff --git a/lib/CL/pocl_runtime_config.h b/lib/CL/pocl_runtime_config.h index eb54dd9..8b01fa8 100644 --- a/lib/CL/pocl_runtime_config.h +++ b/lib/CL/pocl_runtime_config.h @@ -29,11 +29,29 @@ extern "C" { #endif +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + int pocl_is_option_set(const char *key); + +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + int pocl_get_int_option(const char *key, int default_value); int pocl_get_bool_option(const char *key, int default_value); + +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + const char* pocl_get_string_option(const char *key, const char *default_value); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + #ifdef __cplusplus } #endif diff --git a/lib/CL/pocl_timing.h b/lib/CL/pocl_timing.h index afcffd9..064d968 100644 --- a/lib/CL/pocl_timing.h +++ b/lib/CL/pocl_timing.h @@ -30,12 +30,20 @@ extern "C" { #endif +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + extern const unsigned pocl_timer_resolution; uint64_t pocl_gettimemono_ns(); int pocl_gettimereal(int *year, int *mon, int *day, int *hour, int *min, int *sec, int* nanosec); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + #ifdef __cplusplus } #endif diff --git a/lib/CL/pocl_util.h b/lib/CL/pocl_util.h index ce10460..66b6f7d 100644 --- a/lib/CL/pocl_util.h +++ b/lib/CL/pocl_util.h @@ -36,6 +36,10 @@ #error aligned malloc unavailable #endif +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -56,6 +60,10 @@ extern "C" { uint32_t byteswap_uint32_t (uint32_t word, char should_swap); float byteswap_float (float word, char should_swap); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + /* set rounding mode */ void pocl_restore_rm (unsigned rm); /* get current rounding mode */ @@ -70,6 +78,10 @@ void pocl_set_ftz (unsigned ftz); unsigned pocl_save_ftz (); void pocl_restore_ftz (unsigned ftz); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + /* Finds the next highest power of two of the given value. */ size_t pocl_size_ceil2 (size_t x); uint64_t pocl_size_ceil2_64 (uint64_t x); @@ -83,7 +95,15 @@ uint64_t pocl_size_ceil2_64 (uint64_t x); * must be a non-zero power of 2. */ +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + void *pocl_aligned_malloc(size_t alignment, size_t size); + +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif #define pocl_aligned_free(x) POCL_MEM_FREE(x) /* locks / unlocks two events in order of their event-id. @@ -127,6 +147,10 @@ check_copy_overlap(const size_t src_offset[3], const size_t region[3], const size_t row_pitch, const size_t slice_pitch); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + /** * Push a command into ready list if all previous events are completed or * in pending_list if the command still has pending dependencies @@ -136,6 +160,10 @@ pocl_command_push (_cl_command_node *node, _cl_command_node * volatile * ready_list, _cl_command_node * volatile * pending_list); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + /** * Return true if a command is ready to execute (no more event in wait list * or false if not @@ -182,10 +210,22 @@ void pocl_abort_on_pthread_error (int status, unsigned line, const char *func); void pocl_update_event_queued (cl_event event); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + void pocl_update_event_submitted (cl_event event); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + void pocl_update_event_running_unlocked (cl_event event); +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + void pocl_update_event_running (cl_event event); void pocl_update_event_complete_msg (const char *func, unsigned line, @@ -199,6 +239,10 @@ void pocl_update_event_complete_msg (const char *func, unsigned line, void pocl_update_event_failed (cl_event event); +#ifdef __GNUC__ +#pragma GCC visibility push(hidden) +#endif + const char* pocl_status_to_str (int status); @@ -216,6 +260,10 @@ float half_to_float (uint16_t value); } #endif +#ifdef __GNUC__ +#pragma GCC visibility pop +#endif + /* Common macro for cleaning up "*GetInfo" API call implementations. * All the *GetInfo functions have been specified to look alike, * and have been implemented to use the same variable names, so this -- 2.30.2